# 定义读取登陆数据的函数
import json


def read_login_data(filename):
    """
    :param filename:
    :return:
    """
    with open(file=filename, mode='r', encoding="utf-8")as f:
        jsonDate = json.load(f)
    empty_list = []
    for i in jsonDate:
        empty_list.append(tuple(i.values()))
    print("转换后为列表元祖: ", empty_list)
    return empty_list


def read_emp_data(filename, api_name):
    """

    :param filename: 外部传入的员工数据文件路径
    :param api_name:数据文件中各个接口的名称
    :return:
    """
    with open(file=filename, mode='r', encoding="utf-8")as f:
        jsonDate = json.load(f)
        empty_list = []
        for i in jsonDate:
            temp_data = i.get(api_name)
            empty_list.append(tuple(temp_data.values()))
        print("转化后的数据为: ", empty_list)
        return empty_list


if __name__ == '__main__':
    filename = "C:\Pyproject\day07_test_ihrm/data/login_data.json"
    read_login_data(filename)
    filename = "C:\Pyproject\day07_test_ihrm/data/empolyee.json"
    read_emp_data(filename, "query_emp_list")
    read_emp_data(filename, "add_emp")
    read_emp_data(filename, "query_emp")
    read_emp_data(filename, "modify_emp")
    read_emp_data(filename, "delete_emp")
